/**
 * Created by thomas on 2017/5/2.
 */
import React,{Component} from 'react';
import { withRouter } from 'react-router-dom'
import Loading from  './loading_page';
class Bus extends React.Component{
    constructor(props) {
        super(props);
        this.state= {
            select_m:false,
            hid_load:true
        };
    }
    change_ul(e){
        sessionStorage.setItem("sex",
            this.state.select_m ? "man" :"wm",
        );
        this.setState({
            hid_load:false
        },()=>{
            let img =new Image();
            img.src = sessionStorage.getItem("img_path")+"/weight.jpg?1";
            img.onload = function(){
                img.onload = null;
                setTimeout(()=>{
                    this.props.history.push(e);
                },300)
            }.bind(this);
        });
    }
    get_sex_c(e){{

    }}
    preloadimages(arr){
        let newimages=[];
       // let arr=(typeof arr!="object")? [arr] : arr  //确保参数总是数组
        for (let i=0; i<arr.length; i++){
            newimages[i]=new Image();
            newimages[i].src=arr[i]
        }
    }
    componentWillMount(){
        document.getElementsByTagName("title")[0].innerText="完善资料";
        // this.preloadimages(
        //     ["../static/man_logo_s.png","../static/man_logo.png","../static/girl_logo_s.png","../static/girl_logo.png"]
        // )
    }
    render() {
        return (
            <div className="get_sex_contain">
                <Loading hid_load={this.state.hid_load}/>
                {/*<Loading hid_load={this.state.hid_load}/>*/}
                <div className="get_sex_man box_s">
                        <div className="get_sex_man_top_n">
                            请选择你的性别
                        </div>
                        <img src={this.state.select_m ?sessionStorage.getItem("img_path")+"/man_logo_s.png":sessionStorage.getItem("img_path")+"/man_logo.png"} alt=""  ref="man"
                             className="man_img"
                             onClick={
                                     () =>{this.get_sex_c("man");
                                     this.setState({
                                         select_m:!this.state.select_m
                                     })
                                 }}/>
                        <div className="get_sex_man_bot_n">
                            我是男生
                        </div>
                </div>
                <div className="get_sex_man g_bg_C">
                    <img src={!this.state.select_m?sessionStorage.getItem("img_path")+"/girl_logo_s.png":sessionStorage.getItem("img_path")+"/girl_logo.png"} alt="" ref="wm" className="man_img m_t_56"
                         onClick={
                             ()=> {
                                 this.get_sex_c("w");
                                 this.setState({
                                     select_m:!this.state.select_m
                                 })

                             }
                         }/>
                    <div className="get_sex_man_bot_n g_bg_C">
                        我是女生
                    </div>
                </div>
                <div onClick={(e) =>{
                    e.stopPropagation();
                    this.change_ul("/tacos/Cart");
                    this.props.get_dot(2)
                }}
                     className="next_step">下一步</div>
            </div>

        );
    }
}
export default withRouter(Bus);
